﻿using Mafool.Core.Http;
using Microsoft.AspNetCore.Http;
using NetCoreApiDemo;
using NetCoreApiDemo.Helpers;

namespace Mafool.Core.Http;

/// <summary>
/// HttpContext上下文
/// </summary>
public static class HttpContextHelper
{
    private static IHttpContextAccessor _contextAccessor;

    /// <summary>
    /// 注入IHttpContextAccessor获取HttpContext上下文
    /// </summary>
    /// <param name="contextAccessor"></param>
    public static void Configure(IHttpContextAccessor contextAccessor)
    {
        _contextAccessor = contextAccessor;
    }

    /// <summary>
    /// HttpContext上下文
    /// </summary>
    public static HttpContext Current => _contextAccessor.HttpContext;
}
